using System;

namespace FwkLight.Domain.Fetching
{
  public interface IPartialFetchingStrategy<T>
  {
    void ApplyStrategyOn (IMultiCriteriaFetcher<T> repository );
    bool HasChanges { get; set; }
  }

  public abstract class PartialFetchingStrategy<T> : IPartialFetchingStrategy<T>
  {
    public bool HasChanges { get; set; }

    public void ApplyStrategyOn(IMultiCriteriaFetcher<T> repository)
    {
      HasChanges = false;
      repository.ResetChangesCount();
      ApplyPartialStrategyOn(repository);
      if (repository.ChangesCount > 0)
        HasChanges = true;
    }

    public abstract void ApplyPartialStrategyOn(IMultiCriteriaFetcher<T> repository);
  }
}